home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6856 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  49 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Watch out!  C "gotcha!"
  5. Date: 15 Feb 1996 19:38:01 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4g022p$hkc@sun001.spd.dsccc.com>
  8. References: <4fthhh$7th@blackice.winternet.com> <3122762F.6587@oc.com>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <3122762F.6587@oc.com>, Larry Weiss  <lfw@oc.com> wrote:
  12. )Michael Schwarz wrote:
  13. ) > 
  14. ) > Many of you may already know this, but even after ten years of coding
  15. ) > in C, this took my by surprise at first.  A co-worker and I were looking
  16. ) > at some library C code where I work and we noticed that the "default"
  17. ) > clause of one of the switches was misspelled as "defalt."
  18. ) > ...
  19. ) > The thing that scares me the most about this is that either I've never before
  20. ) > made this particular mistake or for the last ten years I've been leaving
  21. ) > behind a number of ticking code bombs...
  22. ) > 
  23. ) > I invite your comments on this (and your knowledge -- I'm a good C programmer
  24. ) > but I don't write compilers and I'm not fully conversant with the full
  25. ) > ANSI spec on C).  Please feel free to e-mail me.
  26. ) > 
  27. )
  28. )
  29. )It's a good observation.   I'd suggest a 
  30. )
  31. )    grep "t:" *.c | grep -v "default" 
  32. )
  33. )or equivalent inspection of any body of C source every once in a while.
  34.  
  35.  
  36. Perhaps just ":" would be better. But of course, someone, somewhere, is
  37. putting the colons on the next line.
  38.  
  39. The really only truly way to watch for this is to use a language which
  40. forces declaration of labels. And does =not= use a label construct for
  41. multiway jump or case statement (C does not have a true case statment,
  42. it has a multiway jump).
  43.  
  44. Mike
  45. ----
  46. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  47.  
  48. I don't speak for DSC.         <- They make me say that.
  49.